﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Data;
using System.Web.UI.WebControls;

namespace lcs.Web.supply
{
    public partial class AddMonthSupply : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request["supplyPlanId"]))
                {
                    Bind(Request["supplyPlanId"]);
                }
            }
        }

        private void Bind(string supplyPlanId)
        {
            DataSet ds = new Maticsoft.BLL.supplyPlan().GetList(" supplyPlanId="+supplyPlanId);

            this.lbl_material.Text = ds.Tables[0].Rows[0]["material"].ToString();
            this.lbl_num.Text = ds.Tables[0].Rows[0]["num"].ToString();
            this.lbl_proid.Text = ds.Tables[0].Rows[0]["proid"].ToString();
            this.lbl_projectname.Text = ds.Tables[0].Rows[0]["projectName"].ToString();
            this.lbl_slink.Text = ds.Tables[0].Rows[0]["slink"].ToString();
            this.lbl_sname.Text = ds.Tables[0].Rows[0]["sname"].ToString();
            this.lbl_unit.Text = ds.Tables[0].Rows[0]["unit"].ToString();

        }
        //生成本月供应计划
        protected void btn_confirm_Click(object sender, EventArgs e)
        {
            string technicalDataStatusDate = this.txt_technicalDataStatusDate.Text;
            string supplyDateStatusDate = this.txt_supplyDateStatusDate.Text;
            int supplyPlanId = 0;

            if (!string.IsNullOrEmpty(Request["supplyPlanId"]))
            {
                supplyPlanId = int.Parse(Request["supplyPlanId"]);
                if (!string.IsNullOrEmpty(technicalDataStatusDate) && !string.IsNullOrEmpty(supplyDateStatusDate))
                {
                    Maticsoft.BLL.supplyPlan sm = new Maticsoft.BLL.supplyPlan();
                    Maticsoft.Model.supplyPlan s = sm.GetModel(supplyPlanId);

                    s.technicalDataStatus = "已确认";
                    s.technicalDataStatusDate = DateTime.Parse(technicalDataStatusDate);
                    s.supplyDateStatus = "已确认";
                    s.supplyDateStatusDate = DateTime.Parse(supplyDateStatusDate);

                    if (sm.Update(s))
                    {
                        Response.Redirect("AddMonthSupplyInfo.aspx?supplyPlanId=" + supplyPlanId);
                    }


                }
                else
                {
                    Maticsoft.Common.MessageBox.Show(this, "请确认日期！");
                }
            }

          
        }
    }
}